// UeRegEdit.h: interface for the UeRegEdit class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_UEREGEDIT_H__68795280_9885_42F7_9161_278625DEB4CE__INCLUDED_)
#define AFX_UEREGEDIT_H__68795280_9885_42F7_9161_278625DEB4CE__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#pragma warning(disable:4800)

class _declspec( dllexport ) UeRegEdit  
{
public:
	class Iterator
	{
		friend class UeRegEdit;
	private:
		Iterator(UeRegEdit * pRegEdit,HKEY hKey){
			ASSERT(pRegEdit);
			ASSERT(hKey);
			m_hKey = hKey;
			m_nIndex = 0;
		}
	public:
		CString First(){
			m_nIndex = 0;
			return m_pRegEdit->EnumSubKey(m_nIndex++,m_hKey);
		}
		CString Next(){
			return m_pRegEdit->EnumSubKey(m_nIndex++,m_hKey);
		}
		BOOL End()
		{
			return m_pRegEdit->EnumSubKey(m_nIndex,m_hKey) == _T("") ? TRUE:FALSE;
		}
		~Iterator(){
			if( m_hKey != NULL )
				RegCloseKey(m_hKey);
		}
	private:
		UeRegEdit * m_pRegEdit;
		HKEY m_hKey;
		UINT m_nIndex;
	};

	friend class Iterator;	
	public:
		UeRegEdit(const CString& strSoftwareKey, HKEY hKey = HKEY_LOCAL_MACHINE);
		
	public:
		virtual ~UeRegEdit();
		
	public:
		CString GetRegKey(LPCTSTR pszKey, LPCTSTR pszName,const CString Default);
		void SetRegValue(LPCTSTR pszKey, LPCTSTR pszName, const CString vValue);
		void SetRegValue(LPCTSTR pszKey, LPCTSTR pszName, const int vValue);
		void SetRegValue(LPCTSTR pszKey, LPCTSTR pszName, const float vValue);
		void SetRegValue(LPCTSTR pszKey, LPCTSTR pszName, const double vValue);
		void SetRegValue(LPCTSTR pszKey, LPCTSTR pszName, const bool vValue);
		long GetRegKey(LPCTSTR pszKey, LPCTSTR pszName,const long Default);
		int GetRegKey(LPCTSTR pszKey,LPCTSTR pszName,const int Default);
		float GetRegKey(LPCTSTR pszKey, LPCTSTR pszName,const float Default);
		bool GetRegKey(LPCTSTR pszKey, LPCTSTR pszName,const bool Default);
		UeRegEdit::Iterator* NewIterator(CString pszKey = CString());
	protected:
		CString EnumSubKey(const UINT& nIndex,const HKEY& hKey);
	private:
		CString g_strSoftwareKey;
		HKEY m_hKey;
};

#endif // !defined(AFX_UEREGEDIT_H__68795280_9885_42F7_9161_278625DEB4CE__INCLUDED_)
